package com.yao.controller;

import com.yao.mapper.UserMapper;
import com.yao.pojo.ManageFinances;
import com.yao.pojo.User;
import com.yao.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

/**
 * @author 妖悲冥
 * @date 2021/5/16 0016   -    8:39
 */

@CrossOrigin
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;

    @RequestMapping("/login")
    public User login(@RequestBody User user) {
        return userService.login(user);
    }

    @RequestMapping("/registered")
    String registered(@RequestBody User user) {
        return userService.registered(user);
    }

    @RequestMapping("/retrieve")
    String retrieve(@RequestBody User user) {
        return userService.retrieve(user);
    }

    @RequestMapping("/getCodeByMail")
    String getCodeByMail(@RequestBody User user) {
        return userService.getCodeByMail(user);
    }

    @RequestMapping("/getCodeBySms")
    String getCodeBySms(@RequestBody User user) {
        return userService.getCodeBySms(user);
    }

    @RequestMapping("/setAvatar")
    void setAvatar(MultipartFile file, String username) {
        userService.setAvatar(file, username);
    }
}
